/*     */ package com.jcrj.action.template;
/*     */ 
/*     */ import com.jcrj.action.BaseAction;
/*     */ import com.jcrj.entity.Bookmarks;
/*     */ import com.jcrj.entity.OSignLimit;
/*     */ import com.jcrj.entity.OUser;
/*     */ import com.jcrj.entity.Signature;
/*     */ import com.jcrj.entity.TemplateFile;
/*     */ import com.jcrj.service.SysLogService;
/*     */ import com.jcrj.service.TemplateService;
/*     */ import com.jcrj.util.FileIo;
/*     */ import java.io.File;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintWriter;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import net.sf.json.JSONObject;
/*     */ 
/*     */ public class TemplateAction extends BaseAction
/*     */ {
/*     */   private List<Bookmarks> markList;
/*     */   private int markId;
/*     */   private Bookmarks bookMark;
/*     */   private TemplateService templateService;
/*     */   private String status;
/*     */   private String[] ids;
/*     */   private List temlateList;
/*     */   private String fileName;
/*     */   private String descript;
/*     */   private String recordID;
/*     */   private String userId;
/*     */   private List<Signature> signList;
/*     */   private Signature signature;
/*     */   private String name;
/*     */   private long pageCount;
/*     */   private long totalCount;
/*     */   private File upload;
/*     */   private String uploadFileName;
/*     */   private String uploadContentType;
/*     */   private SysLogService sysLogService;
/*     */   private String orgs;
/*     */   private String names;
/*     */   private String actornames;
/*     */   private String actorids;
/*     */ 
/*     */   public String bookMarkInit()
/*     */   {
/*  49 */     return this.status;
/*     */   }
/*     */ 
/*     */   public String bookMarkList() {
/*  53 */     this.markList = this.templateService.findBookMarkList();
/*  54 */     return "success";
/*     */   }
/*     */ 
/*     */   public String saveBookMark() {
/*     */     try {
/*  59 */       OUser user = (OUser)super.getSession().get("userInfo");
/*  60 */       this.templateService.saveBookMark(this.bookMark);
/*  61 */       this.sysLogService.saveLog("模板管理", user.getName(), "添加了" + this.bookMark.getBookmarkname() + "的标签");
/*  62 */       super.getResponse().getWriter().write("success");
/*  63 */       super.getResponse().getWriter().flush();
/*     */     } catch (Exception e) {
/*  65 */       e.printStackTrace();
/*     */       try
/*     */       {
/*  68 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e1) {
/*  70 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/*  68 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e) {
/*  70 */         e.printStackTrace();
/*     */       }
/*     */     }
/*     */ 
/*  74 */     return null;
/*     */   }
/*     */ 
/*     */   public String updateBookMark() {
/*     */     try {
/*  79 */       OUser user = (OUser)super.getSession().get("userInfo");
/*  80 */       this.templateService.updateBookMark(this.bookMark);
/*  81 */       this.sysLogService.saveLog("模板管理", user.getName(), "修改了" + this.bookMark.getBookmarkname() + "的标签");
/*  82 */       super.getResponse().getWriter().write("success");
/*  83 */       super.getResponse().getWriter().flush();
/*     */     } catch (Exception e) {
/*  85 */       e.printStackTrace();
/*     */       try
/*     */       {
/*  88 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e1) {
/*  90 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/*  88 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e) {
/*  90 */         e.printStackTrace();
/*     */       }
/*     */     }
/*     */ 
/*  94 */     return null;
/*     */   }
/*     */ 
/*     */   public String getBookMarkById() {
/*  98 */     this.bookMark = this.templateService.getBookMark(this.markId);
/*  99 */     return "success";
/*     */   }
/*     */ 
/*     */   public String deleteBookMark() {
/*     */     try {
/* 104 */       OUser user = (OUser)super.getSession().get("userInfo");
/* 105 */       this.templateService.deleteBookMark(this.ids);
/* 106 */       this.sysLogService.saveLog("模板管理", user.getName(), "删除了某些标签信息");
/* 107 */       super.getResponse().getWriter().write("success");
/* 108 */       super.getResponse().getWriter().flush();
/*     */     } catch (Exception e) {
/* 110 */       e.printStackTrace();
/*     */       try
/*     */       {
/* 113 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e1) {
/* 115 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/* 113 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e) {
/* 115 */         e.printStackTrace();
/*     */       }
/*     */     }
/* 118 */     return null;
/*     */   }
/*     */ 
/*     */   public String templateFileList() {
/*     */     try {
/* 123 */       this.totalCount = this.templateService.countTemplate().longValue();
/* 124 */       this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
/* 125 */       if (super.getCurrentPage() > this.pageCount) {
/* 126 */         super.setCurrentPage(Long.valueOf(this.pageCount).intValue());
/*     */       }
/* 128 */       this.temlateList = this.templateService.findTemplateList(super.getCurrentPage());
/*     */     } catch (Exception e) {
/* 130 */       e.printStackTrace();
/*     */     }
/* 132 */     return "success";
/*     */   }
/*     */ 
/*     */   public String templateContentList()
/*     */   {
/*     */     try {
/* 138 */       this.temlateList = this.templateService.findTemplateList();
/*     */     } catch (Exception e) {
/* 140 */       e.printStackTrace();
/*     */     }
/* 142 */     return "success";
/*     */   }
/*     */ 
/*     */   public String saveTemplateFile()
/*     */   {
/*     */     try {
/* 148 */       OUser user = (OUser)super.getSession().get("userInfo");
/* 149 */       if ((this.userId == null) || ("".equals(this.userId))) {
/* 150 */         setUserId(user.getId().toString());
/*     */       }
/* 152 */       this.templateService.updateTemplateByName(this.fileName, this.descript, this.recordID, this.userId);
/* 153 */       this.sysLogService.saveLog("模板管理", user.getName(), "添加了" + this.fileName + "模板");
/*     */     } catch (Exception e) {
/* 155 */       e.printStackTrace();
/*     */     }
/* 157 */     return "success";
/*     */   }
/*     */ 
/*     */   public String deleteTemplateFile() {
/*     */     try {
/* 162 */       OUser user = (OUser)super.getSession().get("userInfo");
/* 163 */       this.templateService.deleteTemplate(this.ids);
/* 164 */       this.sysLogService.saveLog("模板管理", user.getName(), "删除了某些模板");
/* 165 */       super.getResponse().getWriter().write("success");
/* 166 */       super.getResponse().getWriter().flush();
/*     */     } catch (Exception e) {
/* 168 */       e.printStackTrace();
/*     */       try
/*     */       {
/* 171 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e1) {
/* 173 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/* 171 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e) {
/* 173 */         e.printStackTrace();
/*     */       }
/*     */     }
/* 176 */     return null;
/*     */   }
/*     */ 
/*     */   public String loadTemplateFile()
/*     */   {
/*     */     try
/*     */     {
/* 183 */       TemplateFile template = this.templateService.getTemplateFileById(this.recordID);
/* 184 */       JSONObject json = new JSONObject();
/* 185 */       json.put("template", template);
/* 186 */       super.getResponse().getWriter().write(json.toString());
/* 187 */       super.getResponse().getWriter().flush();
/*     */     } catch (IOException e) {
/* 189 */       e.printStackTrace();
/*     */       try
/*     */       {
/* 192 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e1) {
/* 194 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/* 192 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e) {
/* 194 */         e.printStackTrace();
/*     */       }
/*     */     }
/* 197 */     return null;
/*     */   }
/*     */ 
/*     */   public String signatureManger() {
/*     */     try {
/* 202 */       this.totalCount = this.templateService.countSignature(this.name).longValue();
/* 203 */       this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
/* 204 */       if (super.getCurrentPage() > this.pageCount) {
/* 205 */         super.setCurrentPage(Long.valueOf(this.pageCount).intValue());
/*     */       }
/* 207 */       this.signList = this.templateService.findSignatureList(this.name, super.getCurrentPage());
/*     */     } catch (Exception e) {
/* 209 */       e.printStackTrace();
/*     */     }
/* 211 */     return "success";
/*     */   }
/*     */ 
/*     */   public String saveSignature() {
/*     */     try {
/* 216 */       OUser user = (OUser)super.getSession().get("userInfo");
/* 217 */       if ((this.upload != null) && (!"".equals(this.upload))) {
/* 218 */         String type = this.uploadFileName.substring(this.uploadFileName.indexOf("."));
/* 219 */         byte[] body = FileIo.getBytesFromFile(this.upload);
/* 220 */         this.signature.setMarkbody(body);
/* 221 */         this.signature.setMarktype(type);
/* 222 */         this.signature.setMarksize(Integer.valueOf(body.length));
/*     */       }
/* 224 */       this.signature.setMarkdate(new Date());
/* 225 */       this.signature.setUsername(user.getName());
/* 226 */       this.signature.setUserId(user.getId());
/* 227 */       this.templateService.saveSignature(this.signature, this.orgs, this.names, this.actorids, this.actornames);
/* 228 */       this.sysLogService.saveLog("签章管理", user.getName(), "添加了" + this.signature.getMarkname() + "的签章信息");
/* 229 */       super.getResponse().setCharacterEncoding("GBK");
/* 230 */       super.getResponse().getWriter().write("<script type=\"text/javascript\"> alert('操作成功！');window.close();window.opener.location.href='signatureManger.action';</script>");
/* 231 */       super.getResponse().getWriter().flush();
/*     */     } catch (Exception e) {
/* 233 */       e.printStackTrace();
/*     */       try
/*     */       {
/* 236 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e1) {
/* 238 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/* 236 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e) {
/* 238 */         e.printStackTrace();
/*     */       }
/*     */     }
/* 241 */     return null;
/*     */   }
/*     */   public String getSignatureById() {
/* 244 */     this.signature = this.templateService.getSignatureById(Integer.valueOf(this.markId));
/* 245 */     this.orgs = "";
/* 246 */     this.names = "";
/* 247 */     this.actorids = "";
/* 248 */     this.actornames = "";
/* 249 */     List<OSignLimit> list = this.templateService.getLimitBySignId(this.signature.getSignatureid());
/* 250 */     if ((list != null) && (!list.isEmpty())) {
/* 251 */       for (OSignLimit limit : list) {
/* 252 */         if ("org".equals(limit.getType())) {
/* 253 */           if ("".equals(this.orgs)) {
/* 254 */             this.orgs = limit.getIds().toString();
/* 255 */             this.names = limit.getNames();
/*     */           } else {
/* 257 */             this.orgs = (this.orgs + "," + limit.getIds().toString());
/* 258 */             this.names = (this.names + "," + limit.getNames());
/*     */           }
/* 260 */         } else if ("user".equals(limit.getType())) {
/* 261 */           if ("".equals(this.actorids)) {
/* 262 */             this.actorids = limit.getIds().toString();
/* 263 */             this.actornames = limit.getNames();
/*     */           } else {
/* 265 */             this.actorids = (this.actorids + "," + limit.getIds().toString());
/* 266 */             this.actornames = (this.actornames + "," + limit.getNames());
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/* 271 */     return "success";
/*     */   }
/*     */ 
/*     */   public String updateSignature()
/*     */   {
/*     */     try {
/* 277 */       OUser user = (OUser)super.getSession().get("userInfo");
/* 278 */       Signature sign = this.templateService.getSignatureById(this.signature.getSignatureid());
/* 279 */       if ((this.upload != null) && (!"".equals(this.upload))) {
/* 280 */         String type = this.uploadFileName.substring(this.uploadFileName.indexOf("."));
/* 281 */         byte[] body = FileIo.getBytesFromFile(this.upload);
/* 282 */         sign.setMarkbody(body);
/* 283 */         sign.setMarktype(type);
/* 284 */         sign.setMarksize(Integer.valueOf(body.length));
/*     */       }
/* 286 */       sign.setMarkname(this.signature.getMarkname());
/* 287 */       sign.setPx(this.signature.getPx());
/* 288 */       this.templateService.updateSignature(sign, this.orgs, this.names, this.actorids, this.actornames);
/* 289 */       this.sysLogService.saveLog("签章管理", user.getName(), "修改了" + this.signature.getMarkname() + "的签章信息");
/* 290 */       super.getResponse().setCharacterEncoding("GBK");
/* 291 */       super.getResponse().getWriter().write("<script type=\"text/javascript\"> alert('操作成功！');window.close();window.opener.location.href='signatureManger.action';</script>");
/* 292 */       super.getResponse().getWriter().flush();
/*     */     } catch (Exception e) {
/* 294 */       e.printStackTrace();
/*     */     }
/* 296 */     return null;
/*     */   }
/*     */ 
/*     */   public String deleteSignature() {
/*     */     try {
/* 301 */       OUser user = (OUser)super.getSession().get("userInfo");
/* 302 */       this.templateService.deleteSignature(this.ids);
/* 303 */       this.sysLogService.saveLog("签章管理", user.getName(), "删除了某些签章");
/* 304 */       super.getResponse().getWriter().write("success");
/* 305 */       super.getResponse().getWriter().flush();
/*     */     } catch (IOException e) {
/* 307 */       e.printStackTrace();
/*     */       try
/*     */       {
/* 310 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e1) {
/* 312 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/* 310 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e) {
/* 312 */         e.printStackTrace();
/*     */       }
/*     */     }
/*     */ 
/* 316 */     return null;
/*     */   }
/*     */ 
/*     */   public String getSignatureObj() {
/* 320 */     this.signature = this.templateService.getSignatureObj(this.markId);
/* 321 */     return "success";
/*     */   }
/*     */ 
/*     */   public String updateSignaturePass() {
/*     */     try {
/* 326 */       OUser user = (OUser)super.getSession().get("userInfo");
/* 327 */       Signature s = this.templateService.getSignatureObj(this.signature.getSignatureid().intValue());
/* 328 */       s.setPassword(this.signature.getPassword());
/* 329 */       this.templateService.updateSignature(s);
/* 330 */       this.sysLogService.saveLog("签章管理", user.getName(), "修改了" + s.getMarkname() + "的签章密码");
/* 331 */       super.getResponse().getWriter().write("success");
/* 332 */       super.getResponse().getWriter().flush();
/*     */     } catch (Exception e) {
/* 334 */       e.printStackTrace();
/*     */       try
/*     */       {
/* 337 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e1) {
/* 339 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/* 337 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e) {
/* 339 */         e.printStackTrace();
/*     */       }
/*     */     }
/* 342 */     return null;
/*     */   }
/*     */ 
/*     */   public List<Signature> getSignList() {
/* 346 */     return this.signList;
/*     */   }
/*     */ 
/*     */   public void setSignList(List<Signature> signList) {
/* 350 */     this.signList = signList;
/*     */   }
/*     */ 
/*     */   public List<Bookmarks> getMarkList() {
/* 354 */     return this.markList;
/*     */   }
/*     */   public void setMarkList(List<Bookmarks> markList) {
/* 357 */     this.markList = markList;
/*     */   }
/*     */   public int getMarkId() {
/* 360 */     return this.markId;
/*     */   }
/*     */   public void setMarkId(int markId) {
/* 363 */     this.markId = markId;
/*     */   }
/*     */   public Bookmarks getBookMark() {
/* 366 */     return this.bookMark;
/*     */   }
/*     */   public void setBookMark(Bookmarks bookMark) {
/* 369 */     this.bookMark = bookMark;
/*     */   }
/*     */   public TemplateService getTemplateService() {
/* 372 */     return this.templateService;
/*     */   }
/*     */   public void setTemplateService(TemplateService templateService) {
/* 375 */     this.templateService = templateService;
/*     */   }
/*     */ 
/*     */   public String getStatus() {
/* 379 */     return this.status;
/*     */   }
/*     */ 
/*     */   public void setStatus(String status) {
/* 383 */     this.status = status;
/*     */   }
/*     */ 
/*     */   public String[] getIds() {
/* 387 */     return this.ids;
/*     */   }
/*     */ 
/*     */   public void setIds(String[] ids) {
/* 391 */     this.ids = ids;
/*     */   }
/*     */ 
/*     */   public List getTemlateList() {
/* 395 */     return this.temlateList;
/*     */   }
/*     */ 
/*     */   public void setTemlateList(List temlateList) {
/* 399 */     this.temlateList = temlateList;
/*     */   }
/*     */ 
/*     */   public String getFileName() {
/* 403 */     return this.fileName;
/*     */   }
/*     */ 
/*     */   public void setFileName(String fileName) {
/* 407 */     this.fileName = fileName;
/*     */   }
/*     */ 
/*     */   public String getDescript() {
/* 411 */     return this.descript;
/*     */   }
/*     */ 
/*     */   public void setDescript(String descript) {
/* 415 */     this.descript = descript;
/*     */   }
/*     */ 
/*     */   public String getRecordID() {
/* 419 */     return this.recordID;
/*     */   }
/*     */ 
/*     */   public void setRecordID(String recordID) {
/* 423 */     this.recordID = recordID;
/*     */   }
/*     */ 
/*     */   public Signature getSignature() {
/* 427 */     return this.signature;
/*     */   }
/*     */ 
/*     */   public void setSignature(Signature signature) {
/* 431 */     this.signature = signature;
/*     */   }
/*     */ 
/*     */   public String getName() {
/* 435 */     return this.name;
/*     */   }
/*     */ 
/*     */   public void setName(String name) {
/* 439 */     this.name = name;
/*     */   }
/*     */ 
/*     */   public long getPageCount() {
/* 443 */     return this.pageCount;
/*     */   }
/*     */ 
/*     */   public void setPageCount(long pageCount) {
/* 447 */     this.pageCount = pageCount;
/*     */   }
/*     */ 
/*     */   public long getTotalCount() {
/* 451 */     return this.totalCount;
/*     */   }
/*     */ 
/*     */   public void setTotalCount(long totalCount) {
/* 455 */     this.totalCount = totalCount;
/*     */   }
/*     */ 
/*     */   public File getUpload() {
/* 459 */     return this.upload;
/*     */   }
/*     */ 
/*     */   public void setUpload(File upload) {
/* 463 */     this.upload = upload;
/*     */   }
/*     */ 
/*     */   public String getUploadFileName() {
/* 467 */     return this.uploadFileName;
/*     */   }
/*     */ 
/*     */   public void setUploadFileName(String uploadFileName) {
/* 471 */     this.uploadFileName = uploadFileName;
/*     */   }
/*     */ 
/*     */   public String getUploadContentType() {
/* 475 */     return this.uploadContentType;
/*     */   }
/*     */ 
/*     */   public void setUploadContentType(String uploadContentType) {
/* 479 */     this.uploadContentType = uploadContentType;
/*     */   }
/*     */ 
/*     */   public SysLogService getSysLogService() {
/* 483 */     return this.sysLogService;
/*     */   }
/*     */ 
/*     */   public void setSysLogService(SysLogService sysLogService) {
/* 487 */     this.sysLogService = sysLogService;
/*     */   }
/*     */ 
/*     */   public String getUserId() {
/* 491 */     return this.userId;
/*     */   }
/*     */ 
/*     */   public void setUserId(String userId) {
/* 495 */     this.userId = userId;
/*     */   }
/*     */ 
/*     */   public String getOrgs() {
/* 499 */     return this.orgs;
/*     */   }
/*     */ 
/*     */   public void setOrgs(String orgs) {
/* 503 */     this.orgs = orgs;
/*     */   }
/*     */ 
/*     */   public String getNames() {
/* 507 */     return this.names;
/*     */   }
/*     */ 
/*     */   public void setNames(String names) {
/* 511 */     this.names = names;
/*     */   }
/*     */ 
/*     */   public String getActornames() {
/* 515 */     return this.actornames;
/*     */   }
/*     */ 
/*     */   public void setActornames(String actornames) {
/* 519 */     this.actornames = actornames;
/*     */   }
/*     */ 
/*     */   public String getActorids() {
/* 523 */     return this.actorids;
/*     */   }
/*     */ 
/*     */   public void setActorids(String actorids) {
/* 527 */     this.actorids = actorids;
/*     */   }
/*     */ }

/* Location:           /Volumes/work/oa/WEB-INF/classes/
 * Qualified Name:     com.jcrj.action.template.TemplateAction
 * JD-Core Version:    0.6.0
 */